package gdut.imis.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import gdut.imis.Utils.Result;
import gdut.imis.domain.StudentGrade;
import gdut.imis.enums.Status;
import gdut.imis.mapper.StudentGradeMapper;
import gdut.imis.service.StudentGradeService;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/8 19:17
 */
@Service
public class StudentGradeServiceImpl extends ServiceImpl<StudentGradeMapper, StudentGrade> implements StudentGradeService {

    /***
     * 新增学生成绩档案
     * @param: studentGrade
     * @return Result
     */
    @Override
    public Result addStudentGrade(StudentGrade studentGrade) {
        if (Objects.isNull(studentGrade)) {
            return Result.errorWithArgs(Status.REQUEST_PARAMS_NOT_VALID_ERROR, "studentGrade");
        }
        boolean flag = this.save(studentGrade);
        if (flag) {
            return Result.success();
        }
        return Result.errorWithArgs(Status.FAILED, "新增学生课程成绩失败");
    }
}
